package com.lmax.disruptor.custom.group2;

import com.lmax.disruptor.EventHandler;

import java.util.concurrent.atomic.AtomicInteger;

public class Consumer implements EventHandler<Order>
{
    private final String consumerId;
    private static final AtomicInteger count = new AtomicInteger(0);

    public Consumer(final String consumerId)
    {
        this.consumerId = consumerId;
    }

    public void onEvent(final Order order) throws Exception
    {
//        System.out.println("当前消费者：" + this.consumerId + ",消费消息：" + order);
        count.incrementAndGet();
    }

    public int getCount()
    {
        return count.get();
    }

    @Override
    public void onEvent(final Order event, final long sequence, final boolean endOfBatch) throws Exception
    {
        System.out.println("当前消费者 " + this.consumerId + "--- seq--" + sequence);
        onEvent(event);
    }
}